package com.area.cth.mapper;

import com.area.cth.pojo.Post;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PostMapper extends BaseMapper<Post> {
    @Insert("insert into post(create_user,title,content,img1,img2,img3,img4,img5,img6,img7,img8,img9,create_time,update_time) " +
            "values (#{createUser},#{title},#{content},#{img1},#{img2},#{img3},#{img4},#{img5},#{img6},#{img7},#{img8},#{img9},#{createTime},#{updateTime})")
    void addPost(Post p);

    Post getPostById(Integer id);

    @Select("select * from post")
    List<Post> getPostList();

    @Select("select * from post where create_user=#{id}")
    List<Post> getMyPostList(Integer id);

    @Update("update post set title=#{title},content=#{content},update_time=#{updateTime} where id=#{id}")
    void updatePost(Post p);

    @Delete("delete from post where id=#{id}")
    void deletePost(Integer id);

    List<Post> searchPost(String keyword);

    @Select("select * from post where create_user=#{userId}")
    List<Post> getPostByUserList(Integer userId);
}
